package com.bishe.supermarket.controller;

import com.bishe.supermarket.pojo.Save;
import com.bishe.supermarket.pojo.vo.Status;
import com.bishe.supermarket.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class ShopController {

    @Autowired
    ShopService shopService;

    //地址转换

    @RequestMapping("shop")
    public  String shop(){

      return "caiGou";
    }
    //进货地址转换
    @RequestMapping("jinhuoAd")
    public String jinhuoAd(){


        return "jinHuo";
    }
    //回退地址转换

    @RequestMapping("backAd")
    public String backAd(HttpSession httpSession){

        List<Save> saveList = shopService.backCom();
        httpSession.setAttribute("saves",saveList);

        return "backShop";
    }
    //接收上货信息

    @RequestMapping("receiveShop")
    public String  receiveShop(int storeId, String comName, String comCategory, int comNum, int comPrimeCost, int comPrice, HttpSession httpSession){

      Status status =  shopService.jinHuo(storeId,comName,comCategory,comNum,comPrimeCost,comPrice);

      httpSession.setAttribute("jinhuo",status);
     return "jinHuoMsg";
    }

    //接收回退数据

    @RequestMapping("receiveHuo")
    public String receiveHuo(String comName,int comNum,HttpSession httpSession){

        Status status = shopService.backHuo(comName,comNum);

        httpSession.setAttribute("huitui",status);

        return "backShopMsg";
    }
}
